package epam_java.jsontest;

import java.util.Arrays;

 public class UserTest {

    public UserTest() {
    }
    public UserTest(long userId, String userName, String login, String pass, String currentAcces) {
        this.userId = userId;
        this.userName = userName;
        this.login = login;
        this.pass = pass;
        this.currentAcces = currentAcces;
    }

    /**
     * id identificated user
     */

    private long userId;
    /**
     * users login;
     */
    /**
     * user name
     */
    private String userName;
    /**
     * user login
     */
    private String login;
    /**
     * password of user
     */
    private String pass;
    /**
     * acces rights of current user;
     */
    private String currentAcces;

    /**
     * @return the userId
     */
    private double doublefavouriteNumbers[];
    private String favouriteStrings[];
    private int intfavouriteNumbers[];
    public Long getUserId() {
        return userId;
    }

    /**
     * @param userId the userId to set
     */
    public void setUserId(Long userId) {
        this.setUserId((long) userId);
    }

    /**
     * @return the login
     */
    public String getLogin() {
        return login;
    }

    /**
     * @param login the login to set
     */
    public void setLogin(String login) {
        this.login = login;
    }

    /**
     * @return the pass
     */
    public String getPass() {
        return pass;
    }

    /**
     * @param pass the pass to set
     */
    public void setPass(String pass) {
        this.pass = pass;
    }

    /**
     * @return the currentAcces
     */
    public String getCurrentAcces() {
        return currentAcces;
    }

    /**
     * @param currentAcces the currentAcces to set
     */
    public void setCurrentAcces(String currentAcces) {
        this.currentAcces = currentAcces;
    }
    /**
     * refresh login and password in database
     */
    public void refreshInBd(){

    }
        /**
     * @param userId the userId to set
     */
    public void setUserId(long userId) {
        this.userId = userId;
    }

    /**
     * @return the userName
     */
    public String getUserName() {
        return userName;
    }

    /**
     * @param userName the userName to set
     */
    public void setUserName(String userName) {
        this.userName = userName;
    }
public String toString(){
    StringBuilder builder=new StringBuilder();
    builder.append("login= "+ getLogin() +"; ");
    builder.append("userId= "+ getUserId() +"; ");
    builder.append("userName= "+ getUserName() +"; ");
    builder.append("password= "+ getPass() +"; ");
    builder.append("Acces= "+ getCurrentAcces() +"; \n ");
    if(getFavouriteStrings()!=null){
    builder.append("favouriteStrings= [");
    for(String s: getFavouriteStrings()){
        builder.append("\"" + s + "\",");
    }
    builder.replace(builder.length()-1,builder.length(), "]; ");
    }
    builder.append("doublefavouriteNumbers= [");
    for(double s: getDoublefavouriteNumbers()){
        builder.append("" + s + ",");
    }
    builder.replace(builder.length()-1,builder.length(), "]; ");
    builder.append("intfavouriteNumbers= [");
    for(int s: getIntfavouriteNumbers()){
        builder.append("" + s + ",");
    }
    builder.replace(builder.length()-1,builder.length(), "]");
    return builder.toString();
}

    /**
     * @return the doublefavouriteNumbers
     */
    public double[] getDoublefavouriteNumbers() {
        return doublefavouriteNumbers;
    }

    /**
     * @param doublefavouriteNumbers the doublefavouriteNumbers to set
     */
    public void setDoublefavouriteNumbers(double[] doublefavouriteNumbers) {
        this.doublefavouriteNumbers = doublefavouriteNumbers;
    }

    /**
     * @return the favouriteStrings
     */
    public String[] getFavouriteStrings() {
        return favouriteStrings;
    }

    /**
     * @param favouriteStrings the favouriteStrings to set
     */
    public void setFavouriteStrings(String[] favouriteStrings) {
        this.favouriteStrings = favouriteStrings;
    }

    /**
     * @return the intfavouriteNumbers
     */
    public int[] getIntfavouriteNumbers() {
        return intfavouriteNumbers;
    }

    /**
     * @param intfavouriteNumbers the intfavouriteNumbers to set
     */
    public void setIntfavouriteNumbers(int[] intfavouriteNumbers) {
        this.intfavouriteNumbers = intfavouriteNumbers;
    }

    @Override
    public boolean equals(Object obj) {
        if(obj instanceof UserTest){
            if(obj==this) return true;
            UserTest user=(UserTest)obj;
            if(user.getCurrentAcces().compareTo(getCurrentAcces())==0 &&
               user.getLogin().compareTo(getLogin())==0&&
               user.getPass().compareTo(getPass())==0  &&
               user.getUserName().compareTo(getUserName())==0  &&
               Arrays.equals(doublefavouriteNumbers, getDoublefavouriteNumbers()) &&
               Arrays.equals(intfavouriteNumbers, getIntfavouriteNumbers())
                    ) return true;
            return false;
        } else
        return super.equals(obj);
    }

}

